from mcp.server.fastmcp import FastMCP

# 创建四则运算MCP服务
calculator = FastMCP("Calculator Service")

@calculator.tool()
def add(a: float, b: float) -> float:
    """实现两个数的加法运算"""
    return a + b

@calculator.tool()
def subtract(a: float, b: float) -> float:
    """实现两个数的减法运算"""
    return a - b

@calculator.tool()
def multiply(a: float, b: float) -> float:
    """实现两个数的乘法运算"""
    return a * b

@calculator.tool()
def divide(a: float, b: float) -> float:
    """实现两个数的除法运算"""
    if b == 0:
        raise ValueError("除数不能为零")
    return a / b

if __name__ == "__main__":
    calculator.run(transport="stdio")